//
//  main.c
//  DataSort
//
//  Created by rui wang on 11-10-2.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#include <stdio.h>


int  heneita(int numberCount, char A, char B, char C);

int  heneita(int numberCount, char A, char B, char C){
    
    int moveCount;// 移动次数
    int p,q;    
    
    if (numberCount == 1) {
        moveCount=1;
        printf("%d,from %c->%c\n",numberCount,A, C);
    }
    
    else{
        
       p = heneita(numberCount-1, A,C,B); 
       printf("%d,from %c->%c\n",numberCount,A,C);
       q = heneita(numberCount-1, B,A,C);

        moveCount = p + q + 1;  
    }
    
    return moveCount;
}

int main (int argc, const char * argv[])
{
   int n ,val;
    
   scanf("%d",&n);
    
   val = heneita(n,'A','B','C');
    
   printf("need total move %d times\n",val);
    
	return 0;
}

